home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 April / enter-2004-04.iso / files / httrack-3.30.exe / {app} / src / httrack.c < prev    next >
Encoding:
C/C++ Source or Header  |  2003-10-11  |  18.7 KB  |  616 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: htsshow.c console progress info                        */
  34. /* Only used on Linux version                                   */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38. #ifndef _WIN32
  39. #ifndef Sleep
  40. #define Sleep(a) { if (((a)*1000)%1000000) usleep(((a)*1000)%1000000); if (((a)*1000)/1000000) sleep(((a)*1000)/1000000); }
  41. #endif
  42. #endif
  43.  
  44. #include "htsglobal.h"
  45. #include "httrack.h"
  46.  
  47. // htswrap_add
  48. #include "htswrap.h"
  49.  
  50. #if HTS_ANALYSTE_CONSOLE
  51.  
  52. /* specific definitions */
  53. //#include "htsbase.h"
  54. #include <stdio.h>
  55. #include <stdlib.h>
  56. #include <string.h>
  57. #ifdef HAVE_SYS_TYPES_H
  58. #include <sys/types.h>
  59. #endif
  60. #ifdef HAVE_SYS_STAT_H
  61. #include <sys/stat.h>
  62. #endif
  63. #ifdef HAVE_UNISTD_H
  64. #include <unistd.h>
  65. #endif
  66. #include <ctype.h>
  67. #ifdef _WIN32
  68. //#include "Winsock.h"
  69. #endif
  70. /* END specific definitions */
  71.  
  72. // ISO VT100/220 definitions
  73. #define VT_COL_TEXT_BLACK    "30"
  74. #define VT_COL_TEXT_RED      "31"
  75. #define VT_COL_TEXT_GREEN    "32"
  76. #define VT_COL_TEXT_YELLOW   "33"
  77. #define VT_COL_TEXT_BLUE     "34"
  78. #define VT_COL_TEXT_MAGENTA  "35"
  79. #define VT_COL_TEXT_CYAN     "36"
  80. #define VT_COL_TEXT_WHITE    "37"
  81. #define VT_COL_BACK_BLACK    "40"
  82. #define VT_COL_BACK_RED      "41"
  83. #define VT_COL_BACK_GREEN    "42"
  84. #define VT_COL_BACK_YELLOW   "43"
  85. #define VT_COL_BACK_BLUE     "44"
  86. #define VT_COL_BACK_MAGENTA  "45"
  87. #define VT_COL_BACK_CYAN     "46"
  88. #define VT_COL_BACK_WHITE    "47"
  89. //
  90. #define VT_GOTOXY(X,Y)  "\33["Y";"X"f"
  91. #define VT_COLOR(C)     "\33["C"m"
  92. #define VT_RESET        "\33[m"
  93. #define VT_REVERSE      "\33[7m"
  94. #define VT_UNREVERSE    "\33[27m"
  95. #define VT_BOLD         "\33[1m"
  96. #define VT_UNBOLD       "\33[22m"
  97. #define VT_BLINK        "\33[5m"
  98. #define VT_UNBLINK      "\33[25m"
  99. //
  100. #define VT_CLREOL       "\33[K"
  101. #define VT_CLRSOL       "\33[1K"
  102. #define VT_CLRLIN       "\33[2K"
  103. #define VT_CLREOS       "\33[J"
  104. #define VT_CLRSOS       "\33[1J"
  105. #define VT_CLRSCR       "\33[2J"
  106. //
  107. #define csi(X)          printf(s_csi( X ));
  108. void vt_clear(void) {
  109.   printf("%s%s%s",VT_RESET,VT_CLRSCR,VT_GOTOXY("1","0"));
  110. }
  111. void vt_home(void) {
  112.   printf("%s%s",VT_RESET,VT_GOTOXY("1","0"));
  113. }
  114. //
  115.  
  116.  
  117. /*
  118. #define STYLE_STATVALUES VT_COLOR(VT_COL_TEXT_BLACK)
  119. #define STYLE_STATTEXT   VT_COLOR(VT_COL_TEXT_BLUE)   
  120. */
  121. #define STYLE_STATVALUES VT_BOLD
  122. #define STYLE_STATTEXT   VT_UNBOLD
  123. #define STYLE_STATRESET  VT_UNBOLD
  124. #define NStatsBuffer     14
  125. #define MAX_LEN_INPROGRESS 40
  126.  
  127. static int use_show;
  128.  
  129. int main(int argc, char **argv) {
  130.   int ret = 0;
  131.   hts_init();
  132.  
  133.   /*
  134.   hts_htmlcheck_init         = (t_hts_htmlcheck_init)           htswrap_read("init");
  135. Log: "engine: init"
  136.  
  137.   hts_htmlcheck_uninit       = (t_hts_htmlcheck_uninit)         htswrap_read("free");
  138. Log: "engine: free"
  139.  
  140.   hts_htmlcheck_start        = (t_hts_htmlcheck_start)          htswrap_read("start");
  141. Log: "engine: start"
  142.  
  143.   hts_htmlcheck_end          = (t_hts_htmlcheck_end)            htswrap_read("end");
  144. Log: "engine: end"
  145.  
  146.   hts_htmlcheck_chopt        = (t_hts_htmlcheck_chopt)          htswrap_read("change-options");
  147. Log: "engine: change-options"
  148.  
  149.   hts_htmlcheck              = (t_hts_htmlcheck)                htswrap_read("check-html");
  150. Log: "check-html: <url>"
  151.  
  152.   hts_htmlcheck_query        = (t_hts_htmlcheck_query)          htswrap_read("query");
  153.   hts_htmlcheck_query2       = (t_hts_htmlcheck_query2)         htswrap_read("query2");
  154.   hts_htmlcheck_query3       = (t_hts_htmlcheck_query3)         htswrap_read("query3");
  155.   hts_htmlcheck_loop         = (t_hts_htmlcheck_loop)           htswrap_read("loop");
  156.   hts_htmlcheck_check        = (t_hts_htmlcheck_check)          htswrap_read("check-link");
  157. Log: none
  158.  
  159.   hts_htmlcheck_pause        = (t_hts_htmlcheck_pause)          htswrap_read("pause");
  160. Log: "pause: <lockfile>"
  161.  
  162.   hts_htmlcheck_filesave     = (t_hts_htmlcheck_filesave)       htswrap_read("save-file");
  163.   hts_htmlcheck_linkdetected = (t_hts_htmlcheck_linkdetected)   htswrap_read("link-detected");
  164. Log: none
  165.  
  166.   hts_htmlcheck_xfrstatus    = (t_hts_htmlcheck_xfrstatus)      htswrap_read("transfer-status");
  167. Log: 
  168.     "engine: transfer-status: link updated: <url> -> <file>"
  169.   | "engine: transfer-status: link added: <url> -> <file>"
  170.   | "engine: transfer-status: link recorded: <url> -> <file>"
  171.   | "engine: transfer-status: link link error (<errno>, '<err_msg>'): <url>"
  172.   hts_htmlcheck_savename     = (t_hts_htmlcheck_savename  )     htswrap_read("save-name");
  173. Log: 
  174.     "engine: save-name: local name: <url> -> <file>"
  175. */
  176.   
  177.   htswrap_add("init",htsshow_init);
  178.   htswrap_add("free",htsshow_uninit);
  179.   htswrap_add("start",htsshow_start);
  180.   htswrap_add("change-options",htsshow_chopt);
  181.   htswrap_add("end",htsshow_end);
  182.   htswrap_add("check-html",htsshow_checkhtml);
  183.   htswrap_add("loop",htsshow_loop);
  184.   htswrap_add("query",htsshow_query);
  185.   htswrap_add("query2",htsshow_query2);
  186.   htswrap_add("query3",htsshow_query3);
  187.   htswrap_add("check-link",htsshow_check);
  188.   htswrap_add("pause",htsshow_pause);
  189.   htswrap_add("save-file",htsshow_filesave);
  190.   htswrap_add("link-detected",htsshow_linkdetected);
  191.   htswrap_add("transfer-status",htsshow_xfrstatus);
  192.   htswrap_add("save-name",htsshow_savename);
  193.  
  194.   ret = hts_main(argc,argv);
  195.   if (ret) {
  196.     fprintf(stderr, "* %s\n", hts_errmsg());
  197.   }
  198.   return ret;
  199. }
  200.  
  201.  
  202. /* CALLBACK FUNCTIONS */
  203.  
  204. /* Initialize the Winsock */
  205. void __cdecl htsshow_init(void) {
  206. #ifdef _WIN32
  207.   {
  208.     WORD   wVersionRequested;   // requested version WinSock API
  209.     WSADATA wsadata;            // Windows Sockets API data
  210.     int stat;
  211.     wVersionRequested = 0x0101;
  212.     stat = WSAStartup( wVersionRequested, &wsadata );
  213.     if (stat != 0) {
  214.       printf("Winsock not found!\n");
  215.       return;
  216.     } else if (LOBYTE(wsadata.wVersion) != 1  && HIBYTE(wsadata.wVersion) != 1) {
  217.       printf("WINSOCK.DLL does not support version 1.1\n");
  218.       WSACleanup();
  219.       return;
  220.     }
  221.   }
  222. #endif
  223.  
  224. }
  225. void __cdecl htsshow_uninit(void) {
  226. #ifdef _WIN32
  227.   WSACleanup();
  228. #endif
  229. }
  230. int __cdecl htsshow_start(httrackp* opt) {
  231.   use_show=0;
  232.   if (opt->verbosedisplay==2) {
  233.     use_show=1;
  234.     vt_clear();
  235.   }
  236.   return 1; 
  237. }
  238. int __cdecl htsshow_chopt(httrackp* opt) {
  239.   return htsshow_start(opt);
  240. }
  241. int  __cdecl htsshow_end(void) { 
  242.   return 1; 
  243. }
  244. int __cdecl htsshow_checkhtml(char* html,int len,char* url_adresse,char* url_fichier) {
  245.   return 1;
  246. }
  247. int __cdecl htsshow_loop(lien_back* back,int back_max,int back_index,int lien_n,int lien_tot,int stat_time, hts_stat_struct* stats) {    // appelΘ α chaque boucle de HTTrack
  248.   static TStamp prev_mytime=0; /* ok */
  249.   static t_InpInfo SInfo; /* ok */
  250.   //
  251.   TStamp mytime;
  252.   long int rate=0;
  253.   char st[256];
  254.   //
  255.   int stat_written=-1;
  256.   int stat_updated=-1;
  257.   int stat_errors=-1;
  258.   int stat_warnings=-1;
  259.   int stat_infos=-1;
  260.   int nbk=-1;
  261.   LLint nb=-1;
  262.   int stat_nsocket=-1;
  263.   LLint stat_bytes=-1;
  264.   LLint stat_bytes_recv=-1;
  265.   int irate=-1;
  266.   if (stats) {
  267.     stat_written=stats->stat_files;
  268.     stat_updated=stats->stat_updated_files;
  269.     stat_errors=stats->stat_errors;
  270.     stat_warnings=stats->stat_warnings;
  271.     stat_infos=stats->stat_infos;
  272.     nbk=stats->nbk;
  273.     stat_nsocket=stats->stat_nsocket;
  274.     irate=(int)stats->rate;
  275.     nb=stats->nb;
  276.     stat_bytes=stats->nb;
  277.     stat_bytes_recv=stats->HTS_TOTAL_RECV;
  278.   }
  279.  
  280.   if (!use_show)
  281.     return 1;
  282.  
  283.   mytime=mtime_local();
  284.   if ((stat_time>0) && (stat_bytes_recv>0))
  285.     rate=(int)(stat_bytes_recv/stat_time);
  286.   else
  287.     rate=0;    // pas d'infos
  288.  
  289.   /* Infos */
  290.   if (stat_bytes>=0) SInfo.stat_bytes=stat_bytes;      // bytes
  291.   if (stat_time>=0) SInfo.stat_time=stat_time;         // time
  292.   if (lien_tot>=0) SInfo.lien_tot=lien_tot; // nb liens
  293.   if (lien_n>=0) SInfo.lien_n=lien_n;       // scanned
  294.   SInfo.stat_nsocket=stat_nsocket;          // socks
  295.   if (rate>0)  SInfo.rate=rate;                // rate
  296.   if (irate>=0) SInfo.irate=irate;             // irate
  297.   if (SInfo.irate<0) SInfo.irate=SInfo.rate;
  298.   if (nbk>=0) SInfo.stat_back=nbk;
  299.   if (stat_written>=0) SInfo.stat_written=stat_written;
  300.   if (stat_updated>=0) SInfo.stat_updated=stat_updated;
  301.   if (stat_errors>=0)  SInfo.stat_errors=stat_errors;
  302.   if (stat_warnings>=0)  SInfo.stat_warnings=stat_warnings;
  303.   if (stat_infos>=0)  SInfo.stat_infos=stat_infos;
  304.  
  305.  
  306.   if ( ((mytime - prev_mytime)>100) || ((mytime - prev_mytime)<0) ) {
  307.     prev_mytime=mytime;
  308.  
  309.     
  310.     st[0]='\0';
  311.     qsec2str(st,stat_time);
  312.     vt_home();
  313.     printf(
  314.     VT_GOTOXY("1","1")
  315.     VT_CLREOL
  316.                            STYLE_STATTEXT   "Bytes saved:"
  317.                            STYLE_STATVALUES " \t%s"
  318.                            "\t"
  319.     VT_CLREOL
  320.     VT_GOTOXY("40","1")
  321.                            STYLE_STATTEXT   "Links scanned:"
  322.                            STYLE_STATVALUES " \t%d/%d (+%d)"
  323.     VT_CLREOL"\n"VT_CLREOL
  324.     VT_GOTOXY("1","2")
  325.                            STYLE_STATTEXT   "Time:"
  326.                                             " \t"
  327.                            STYLE_STATVALUES "%s"
  328.                            "\t"
  329.     VT_CLREOL
  330.     VT_GOTOXY("40","2")
  331.                            STYLE_STATTEXT   "Files written:"
  332.                                             " \t"
  333.                            STYLE_STATVALUES "%d"
  334.     VT_CLREOL"\n"VT_CLREOL
  335.     VT_GOTOXY("1","3")
  336.                            STYLE_STATTEXT   "Transfer rate:"
  337.                                             " \t"
  338.                            STYLE_STATVALUES "%s (%s)"
  339.                            "\t"
  340.     VT_CLREOL
  341.     VT_GOTOXY("40","3")
  342.                            STYLE_STATTEXT   "Files updated:"
  343.                                             " \t"
  344.                            STYLE_STATVALUES "%d"
  345.     VT_CLREOL"\n"VT_CLREOL
  346.     VT_GOTOXY("1","4")
  347.                            STYLE_STATTEXT   "Active connections:"
  348.                                             " \t"
  349.                            STYLE_STATVALUES "%d"
  350.                            "\t"
  351.     VT_CLREOL
  352.     VT_GOTOXY("40","4")
  353.                            STYLE_STATTEXT   "Errors:"
  354.                            STYLE_STATVALUES " \t"
  355.                            STYLE_STATVALUES "%d"
  356.     VT_CLREOL"\n"
  357.     STYLE_STATRESET
  358.     ,
  359.       /* */
  360.       (char*)int2bytes(SInfo.stat_bytes),
  361.       (int)lien_n,(int)SInfo.lien_tot,(int)nbk,
  362.       (char*)st,
  363.       (int)SInfo.stat_written,
  364.       (char*)int2bytessec(SInfo.irate),(char*)int2bytessec(SInfo.rate),
  365.       (int)SInfo.stat_updated,
  366.       (int)SInfo.stat_nsocket,
  367.       (int)SInfo.stat_errors
  368.       /* */
  369.       );
  370.  
  371.     
  372.     // parcourir registre des liens
  373.     if (back_index>=0) {  // seulement si index passΘ
  374.       int j,k;
  375.       int index=0;
  376.       int ok=0;         // idem
  377.       int l;            // idem
  378.       //
  379.       t_StatsBuffer StatsBuffer[NStatsBuffer];
  380.       
  381.       {
  382.         int i;
  383.         for(i=0;i<NStatsBuffer;i++) {
  384.           strcpybuff(StatsBuffer[i].state,"");
  385.           strcpybuff(StatsBuffer[i].name,"");
  386.           strcpybuff(StatsBuffer[i].file,"");
  387.           strcpybuff(StatsBuffer[i].url_sav,"");
  388.           StatsBuffer[i].back=0;
  389.           StatsBuffer[i].size=0;
  390.           StatsBuffer[i].sizetot=0;
  391.         }
  392.       }
  393.       for(k=0;k<2;k++) {    // 0: lien en cours 1: autres liens
  394.         for(j=0;(j<3) && (index<NStatsBuffer);j++) {  // passe de prioritΘ
  395.           int _i;
  396.           for(_i=0+k;(_i< max(back_max*k,1) ) && (index<NStatsBuffer);_i++) {  // no lien
  397.             int i=(back_index+_i)%back_max;    // commencer par le "premier" (l'actuel)
  398.             if (back[i].status>=0) {     // signifie "lien actif"
  399.               // int ok=0;  // OPTI
  400.               ok=0;
  401.               switch(j) {
  402.               case 0:     // prioritaire
  403.                 if ((back[i].status>0) && (back[i].status<99)) {
  404.                   strcpybuff(StatsBuffer[index].state,"receive"); ok=1;
  405.                 }
  406.                 break;
  407.               case 1:
  408.                 if (back[i].status==99) {
  409.                   strcpybuff(StatsBuffer[index].state,"request"); ok=1;
  410.                 }
  411.                 else if (back[i].status==100) {
  412.                   strcpybuff(StatsBuffer[index].state,"connect"); ok=1;
  413.                 }
  414.                 else if (back[i].status==101) {
  415.                   strcpybuff(StatsBuffer[index].state,"search"); ok=1;
  416.                 }
  417.                 else if (back[i].status==1000) {    // ohh le beau ftp
  418.                   sprintf(StatsBuffer[index].state,"ftp: %s",back[i].info); ok=1;
  419.                 }
  420.                 break;
  421.               default:
  422.                 if (back[i].status==0) {  // prΩt
  423.                   if ((back[i].r.statuscode==200)) {
  424.                     strcpybuff(StatsBuffer[index].state,"ready"); ok=1;
  425.                   }
  426.                   else if ((back[i].r.statuscode>=100) && (back[i].r.statuscode<=599)) {
  427.                     char tempo[256]; tempo[0]='\0';
  428.                     infostatuscode(tempo,back[i].r.statuscode);
  429.                     strcpybuff(StatsBuffer[index].state,tempo); ok=1;
  430.                   }
  431.                   else {
  432.                     strcpybuff(StatsBuffer[index].state,"error"); ok=1;
  433.                   }
  434.                 }
  435.                 break;
  436.               }
  437.               
  438.               if (ok) {
  439.                 char s[HTS_URLMAXSIZE*2];
  440.                 //
  441.                 StatsBuffer[index].back=i;        // index pour + d'infos
  442.                 //
  443.                 s[0]='\0';
  444.                 strcpybuff(StatsBuffer[index].url_sav,back[i].url_sav);   // pour cancel
  445.                 if (strcmp(back[i].url_adr,"file://"))
  446.                   strcatbuff(s,back[i].url_adr);
  447.                 else
  448.                   strcatbuff(s,"localhost");
  449.                 if (back[i].url_fil[0]!='/')
  450.                   strcatbuff(s,"/");
  451.                 strcatbuff(s,back[i].url_fil);
  452.                 
  453.                 StatsBuffer[index].file[0]='\0';
  454.                 {
  455.                   char* a=strrchr(s,'/');
  456.                   if (a) {
  457.                     strncatbuff(StatsBuffer[index].file,a,200);
  458.                     *a='\0';
  459.                   }
  460.                 }
  461.                 
  462.                 if ((l=strlen(s))<MAX_LEN_INPROGRESS)
  463.                   strcpybuff(StatsBuffer[index].name,s);
  464.                 else {
  465.                   // couper
  466.                   StatsBuffer[index].name[0]='\0';
  467.                   strncatbuff(StatsBuffer[index].name,s,MAX_LEN_INPROGRESS/2-2);
  468.                   strcatbuff(StatsBuffer[index].name,"...");
  469.                   strcatbuff(StatsBuffer[index].name,s+l-MAX_LEN_INPROGRESS/2+2);
  470.                 }
  471.                                
  472.                 if (back[i].r.totalsize>0) {  // taille prΘdΘfinie
  473.                   StatsBuffer[index].sizetot=back[i].r.totalsize;
  474.                   StatsBuffer[index].size=back[i].r.size;
  475.                 } else {  // pas de taille prΘdΘfinie
  476.                   if (back[i].status==0) {  // prΩt
  477.                     StatsBuffer[index].sizetot=back[i].r.size;
  478.                     StatsBuffer[index].size=back[i].r.size;
  479.                   } else {
  480.                     StatsBuffer[index].sizetot=8192;
  481.                     StatsBuffer[index].size=(back[i].r.size % 8192);
  482.                   }
  483.                 }
  484.                 index++;
  485.               }
  486.             }
  487.           }
  488.         }
  489.       }
  490.  
  491.       /* LF */
  492.       printf("%s\n",VT_CLREOL);
  493.  
  494.       /* Display current job */
  495.       {
  496.         int parsing=0;
  497.         printf("Current job: ");
  498.         if (!(parsing=hts_is_parsing(-1)))
  499.           printf("receiving files");
  500.         else {
  501.           switch(hts_is_testing()) {
  502.           case 0:
  503.             printf("parsing HTML file (%d%%)",parsing);
  504.             break;
  505.           case 1:
  506.             printf("parsing HTML file: testing links (%d%%)",parsing);
  507.             break;
  508.           case 2:
  509.             printf("purging files");
  510.             break;
  511.           }
  512.         }
  513.         printf("%s\n",VT_CLREOL);
  514.       }
  515.       
  516.       /* Display background jobs */
  517.       {
  518.         int i;
  519.         for(i=0;i<NStatsBuffer;i++) {
  520.           if (strnotempty(StatsBuffer[i].state)) {
  521.             printf(VT_CLREOL" %s - \t%s%s \t%s / \t%s",
  522.               StatsBuffer[i].state,
  523.               StatsBuffer[i].name,
  524.               StatsBuffer[i].file,
  525.               int2bytes(StatsBuffer[i].size),
  526.               int2bytes(StatsBuffer[i].sizetot)
  527.               );
  528.           }
  529.           printf("%s\n",VT_CLREOL);
  530.         }
  531.       }
  532.  
  533.  
  534.     }
  535.  
  536.   }
  537.  
  538.  
  539.  
  540.   return 1;
  541. }
  542. char* __cdecl htsshow_query(char* question) {
  543.   static char s[12]=""; /* ok */
  544.   printf("%s\nPress <Y><Enter> to confirm, <N><Enter> to abort\n",question);
  545.   io_flush; linput(stdin,s,4);
  546.   return s;
  547. }
  548. char* __cdecl htsshow_query2(char* question) {
  549.   static char s[12]=""; /* ok */
  550.   printf("%s\nPress <Y><Enter> to confirm, <N><Enter> to abort\n",question);
  551.   io_flush; linput(stdin,s,4);
  552.   return s;
  553. }
  554. char* __cdecl htsshow_query3(char* question) {
  555.   static char line[256]; /* ok */
  556.   do {
  557.     io_flush; linput(stdin,line,206);
  558.   } while(!strnotempty(line));
  559.   printf("ok..\n");
  560.   return line;
  561. }
  562. int __cdecl htsshow_check(char* adr,char* fil,int status) {
  563.   return -1;
  564. }
  565. void __cdecl htsshow_pause(char* lockfile) {
  566.   while (fexist(lockfile)) {
  567.     Sleep(1000);
  568.   }
  569. }
  570. void __cdecl htsshow_filesave(char* file) {
  571. }
  572. int __cdecl htsshow_linkdetected(char* link) {
  573.   return 1;
  574. }
  575. int __cdecl htsshow_xfrstatus(lien_back* back) {
  576.   return 1;
  577. }
  578. int __cdecl htsshow_savename(char* adr_complete,char* fil_complete,char* referer_adr,char* referer_fil,char* save) {
  579.   return 1;
  580. }
  581.  
  582.  
  583. /* *** Various functions *** */
  584.  
  585.  
  586. int fexist(char* s) {
  587.   struct stat st;
  588.   memset(&st, 0, sizeof(st));
  589.   if (stat(s, &st) == 0) {
  590.     if (S_ISREG(st.st_mode)) {
  591.       return 1;
  592.     }
  593.   }
  594.   return 0;
  595.  
  596. int linput(FILE* fp,char* s,int max) {
  597.   int c;
  598.   int j=0;
  599.   do {
  600.     c=fgetc(fp);
  601.     if (c!=EOF) {
  602.       switch(c) {
  603.         case 13: break;  // sauter CR
  604.         case 10: c=-1; break;
  605.         case 9: case 12: break;  // sauter ces caractΦres
  606.         default: s[j++]=(char) c; break;
  607.       }
  608.     }
  609.   }  while((c!=-1) && (c!=EOF) && (j<(max-1)));
  610.   s[j]='\0';
  611.   return j;
  612. }
  613.  
  614. #endif
  615.